All Packages Class Hierarchy This Package Previous Next Index
Class sun.server.ServiceLog
java.lang.Object
|
+----sun.server.ServiceLog
- public class ServiceLog
- extends Object
- implements Observer
Create a configured log for a service.
Useage of this class would be as follows:
Please note that the example code needs a little more work
to be clear:
Assuming the following property file is read via ServiceConfiguration:
log.chatlog.destination=file
log.chatlog.file.filename=log/chat_log
log.chatlog.level=2
log.chatlog.formatclass=sun.server.util.TraceLog
Then this code:
class ChatServiceLog {
String logName = "chatlog";
ServiceConfiguration serviceConfig;
ServiceLog svcLog;
TraceLog chatLog;
ExProperties props;
ChatServiceLog(ServiceConfiguration serviceConfig, String serviceRoot) {
svcLog = new ServiceLog(logName,serviceConfig,serviceRoot);
chatLog = (TraceLog)svcLog.getLog();
chatLog.write("Log configured");
}
}
Will produce a file in the log directory under service root, named chat_log,
which will contain the line written.
-
ServiceLog(String, ServiceConfiguration, String)
- Create a configured log for a service, using the supplied properties.
-
close()
- Close the service log.
-
configureLog(boolean)
-
-
getFileName()
-
Returns the filename associated with the ServiceLog.
-
getHost()
-
Returns the hostname associated with the ServiceLog.
-
getLog()
- Returns the Log associated with this ServiceLog.
-
getName()
-
Returns the short name of the ServiceLog.
-
getPort()
-
Returns the port number associated with the ServiceLog.
-
update(Observable, Object)
- Routine called when properties are updated by the Observable object.
ServiceLog
public ServiceLog(String name,
ServiceConfiguration serviceConfig,
String serviceRoot) throws IOException
- Create a configured log for a service, using the supplied properties.
getName
public String getName()
- Returns the short name of the ServiceLog. (i.e. "access", "proxy",
"user".)
getLog
public Log getLog()
- Returns the Log associated with this ServiceLog.
getFileName
public String getFileName()
- Returns the filename associated with the ServiceLog. Returns null
if the ServiceLog is not writing to a file.
getHost
public String getHost()
- Returns the hostname associated with the ServiceLog. Returns null
if the ServiceLog is not writing to a socket.
getPort
public int getPort()
- Returns the port number associated with the ServiceLog. Returns -1
if the ServiceLog is not writing to a socket.
update
public void update(Observable o,
Object obj)
- Routine called when properties are updated by the Observable object.
close
public void close()
- Close the service log. Further writes will throw IOExceptions.
configureLog
protected void configureLog(boolean update) throws IOException
All Packages Class Hierarchy This Package Previous Next Index